// .txt

beginzonescript;

variables;

short im_hostile = 0;
short last_abil;
short counter = 0;
short set_ter1 = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	set_name(4800,"Scout Halki");
	if (gf(48,13) > 0)
		erase_char(4800);
	set_name(30001,"Haven Sapper Team");
	set_name(4801,"Counsel Vasilo");
	if ((gf(48,13) == 0) || (gf(48,14) > 0))
		erase_char(30001);
	set_name(30002,"Shade Sentinel");
	set_name(4848,"Vengeful Kranas");
	set_boss_level(4848,1);
	set_percent_adjust(4848,6,-30);

	if (gf(48,14) > 0)
		sf(48,14,11);

	if (gf(48,11) == 0) {
		sf(48,12,0);
		erase_char(30011);
		erase_char(30012);
		}
		else {
			erase_char(30002);
			sf(48,20,1);
			sf(48,21,1);
			sf(48,22,1);
			sf(48,23,1);
			}
		
	set_attack_range(30002,4);

//	add_ability(short which_char_or_group,short which_slot,short which_ability,0);

//	if (is_town_clear(ME))
//		clean_up_town();

	// fix broken flag
	if ((gf(80,12) >= 6) && (gf(48,14) == 0))
		sf(80,12,5);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((set_ter1 == 0) && (gf(48,14) >= 10)) {
		set_ter1 = 1;
		set_terrain(0,28,39,0);
		set_terrain(0,28,42,0);
		}
		

		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4800,"Why did they do this?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4800,"An honor, [P].");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4800,"I am a scout of Haven.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(4800,"Quite a provocation.");


	if (gf(48,14) == 1) {
		sf(48,14,2);
		}
		else if (gf(48,14) == 2) {
			sf(48,14,10);
			toggle_quest(20,10);
			run_game_hardcode(1);
			}
		else if (gf(48,14) == 10) {
			sf(48,14,11);
			erase_char(30001);
			begin_talk_mode(16);
			}
			
	
	//if (gf(,) < 2) {
	//	inc_flag(,,1);
	//	if (gf(,) == 2)
	//		begin_talk_mode();
	//	}

	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 2)) || ((is_town()) && (tick_difference(last_abil,get_current_tick()) > 6))) {
		last_abil = get_current_tick();
		
		if ((on_which_layer() == 0) && (gf(48,11) == 0)) {
			if ((char_ok(4809) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4809);
			if ((char_ok(4810) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4810);
			if ((char_ok(4811) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4811);
			if ((char_ok(4812) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4812);
			if ((char_ok(4813) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4813);
			if ((char_ok(4814) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4814);
			if ((char_ok(4815) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4815);
			if ((char_ok(4816) == FALSE) && (get_ran(1,0,100) < 50)) 
				spawn_creature(4816);
				
			set_name(30002,"Shade Sentinel");
			set_attack_range(30002,4);
			}

		if ((on_which_layer() == 1) && (gf(48,4) > 0) && (gf(48,11) == 0) 
		  && ((party_dist_to_spot(8,20) <= 6) || (party_dist_to_spot(17,20) <= 6) || (party_dist_to_spot(25,20) <= 6))) {
			if ((char_ok(4841) == FALSE) && (get_ran(1,0,100) < 60 + (10 * difficulty()))) {
				spawn_creature(4841);
				set_name(4841,"Shadow Wolf");
				run_text_on_char(4841,"New shadow!",0);
				set_summon_level(4841,2);
				}
			if ((char_ok(4842) == FALSE) && (get_ran(1,0,100) < 60 + (10 * difficulty()))) {
				spawn_creature(4842);
				set_name(4842,"Shadow Wolf");
				run_text_on_char(4842,"New shadow!",0);
				set_summon_level(4842,2);
				}
			if ((char_ok(4843) == FALSE) && (get_ran(1,0,100) < 60 + (10 * difficulty()))) {
				spawn_creature(4843);
				set_name(4843,"Shadow Wolf");
				run_text_on_char(4843,"New shadow!",0);
				set_summon_level(4843,2);
				}
			if ((char_ok(4844) == FALSE) && (get_ran(1,0,100) < 60 + (10 * difficulty()))) {
				spawn_creature(4844);
				set_name(4844,"Shadow Lithan");
				run_text_on_char(4844,"New shadow!",0);
				set_summon_level(4844,2);
				}
			if ((char_ok(4845) == FALSE) && (get_ran(1,0,100) < 60 + (10 * difficulty()))) {
				spawn_creature(4845);
				set_name(4845,"Shadow Lithan");
				run_text_on_char(4845,"New shadow!",0);
				set_summon_level(4845,2);
				}
			if ((char_ok(4846) == FALSE) && (get_ran(1,0,100) < 60 + (10 * difficulty()))) {
				spawn_creature(4846);
				set_name(4846,"Shadow Drake");
				run_text_on_char(4846,"New shadow!",0);
				set_summon_level(4846,2);
				}
			
			}
		}
break;

beginstate 10;
	if (gf(48,15) == 0) {
		activate_hidden_group(7);
		sf(48,15,1);
		}
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

//	print_str("");
//	set_terrain_string_range(".",1);
//	set_terrain_string_range("The sign says - .",1);
